#ifndef __ANALYSIS_OBJECTS__
#define __ANALYSIS_OBJECTS__

#include "iostream"
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include "TObject.h"
#include "TVector3.h"
#include "TH2D.h"
#include "TF1.h"
#include "TCanvas.h"
#include "dirc_objects.h"




class TrackRecon : public TObject
{
public:
	TrackRecon(){}
	~TrackRecon(){}
	
	void clear();
	void printLatest();

	TH1D Hist;
	std::vector < std::string > Options;
	std::vector < double > Sigmas;
	std::vector < double > Areas;
	std::vector < double > ExpectedNumber;
	std::vector < std::vector < double> > Params;
	std::vector < std::string > Funs;

	ClassDef(TrackRecon, 1);
};

class TrackRecons : public TObject
{
public:
	TrackRecons(){}
	~TrackRecons(){}

	std::vector<TrackRecon> Recon;
	
	ClassDef(TrackRecons, 1);
};
// makes and stores histograms for an event
class Analysis : public TObject
{
public:
	Analysis(bool p = false) : print(p) {}
	~Analysis(){}

	void SetData(std::vector< std::vector<double> > data2d){data.clear(); data = data2d; }
	void AddTH1D(const char* name, const char* title, int nbinsx, double xlow, double xup, int which);
	void AddTH2D(const char* name, const char* title, int nbinsx, double xlow, double xup, int nbinsy, double ylow, double yup);

	void SetPrint(bool p = true) {print = p;}

	std::vector<TH1D> Hists1D;
	std::vector<TH2D> Hists2D;
	std::vector< std::vector<double> > data;
	bool print;

	ClassDef(Analysis, 1);
};

// fits histograms to gaussian + polynomial
class Fit : public Analysis
{
public:
	Fit(){}
	~Fit(){}

	void NumPar(int par);
	void Add1DFit(TCanvas *c, TH1D hist, int par, double anglex, int option);
	void Add2DFit(TH2D hist, int par, double anglex, double angley);
	void Find1DCandidates(int nfound, double xpeaks[], int par, std::vector<double> angles);


	std::vector< std::vector<TH1D> > Event1D;
	std::vector< std::vector<TH2D> > Event2D;

	std::vector< std::vector<double> > Candidates1D;

	ClassDef(Fit, 1);
};

#endif